package com.my.chapter7;

public class practice2 extends Detergent{
    public void scrub(){
        append(" practice2.scrub()");
        super.scrub();
    }
    public void sterilize(){
        append(" sterilize()");
    }
    public static void main(String[] args) {
        practice2 t = new practice2();
        t.dilute();
        t.apply();
        t.scrub();
        t.foam();
        t.sterilize();
        System.out.println(t);
    }
}

class Cleanser{
    private String s = "Cleanser";
    public void append(String a){
        s+=a;
    }
    public void dilute(){
        append(" dilute");
    }
    public void apply(){
        append(" apply");
    }
    public void scrub(){
        append(" scrub");
    }

    @Override
    public String toString() {
        return s;
    }

    public static void main(String[] args) {
        Cleanser x = new Cleanser();
        x.dilute();x.apply();x.scrub();
        System.out.println(x);
    }
}

class Detergent extends Cleanser{
    public void scrub(){
        append(" Dtergent.scrub()");
        super.scrub();
    }
    public void foam(){
        append(" foam()");
    }

    public static void main(String[] args) {
        Detergent x= new Detergent();
        x.dilute();
        x.apply();
        x.scrub();
        x.foam();
        System.out.println(x);
    }
}

